/*************************************************
Author: will
Date: 5/31/2013
Description:
Notes: 
*************************************************/

#ifndef __CGoldPriceConfig_h__
#define __CGoldPriceConfig_h__

class CGoldPriceConfigData
{
public:
    CGoldPriceConfigData()
    {

    }

public:
    bool _bHasConfig;

    int _iItemID;                     
    unsigned short _iPrice;    
    unsigned short _iMaxCount;    
    unsigned short _iGoldCount;
};

class CGoldPriceConfig
{
public:
    CGoldPriceConfig()
    {

    }

    int AddConfig(CGoldPriceConfigData& stConfigData)
    {
        if (stConfigData._iItemID <= 0 || stConfigData._iItemID >= _astGoldPriceConfigDatas.GetCount()
            || _astGoldPriceConfigDatas[stConfigData._iItemID]._bHasConfig)
        {
            CT_ERROR(("%d", stConfigData._iItemID));
            return RET_SYS_ERROR;
        }

        _astGoldPriceConfigDatas[stConfigData._iItemID] = stConfigData;
        _astGoldPriceConfigDatas[stConfigData._iItemID]._bHasConfig = true;

        return 0;
    }

    int GetConfig(int iItemID, CGoldPriceConfigData& stConfigData)
    {
        stConfigData._iItemID = iItemID;
        if (stConfigData._iItemID <= 0 || stConfigData._iItemID >= _astGoldPriceConfigDatas.GetCount()
            || !_astGoldPriceConfigDatas[stConfigData._iItemID]._bHasConfig)
        {
            CT_ERROR(("%d", stConfigData._iItemID));
            return RET_SYS_ERROR;
        }

        stConfigData = _astGoldPriceConfigDatas[stConfigData._iItemID];
        return 0;
    }

public:
    CTLib::CTArray<CGoldPriceConfigData, MAX_BUY_GOLD_CONFIG_COUNT> _astGoldPriceConfigDatas;
};

#endif // __CGoldPriceConfig_h__

